﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace SBB.Services.SFTP.Server
{
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class SFTPService : ISFTPService
    {
        #region Class Members
        private MSLogger _logger;
        private ServerListener _sshListener;
        #endregion

        public SFTPService()
        {
            _logger = new MSLogger();

            _logger.Debug("Server initialized");

            SBUtils.Unit.SetLicenseKey("123A2EB227B191D0CCF215E707E9986BA63E23CB933F86547907FE2B26F2B05AAAA35C5DDD78628DE584D2BD34293FC8D99D48C6E5E63172813AAD1CBC07CEE7DBAB2E316C4548B166FBC8689C867CEABD61175494B039F15AE38A1A0C5AF9895624B45E396882C8B096F07B4163292C2ADFEC96CDCC814C900665BB0D0CCC083BCB68252BDE4C4C818E7AE14C5A897995C445D3CA4780858D7AF8F9E5218A4CB7431279293E39FA84820C09B740C5BE7A96B4DCEF8E03E53CC62C33D6D91A7750A55DF364B0A1DD36A0405D0E3EA9AED176B1DE3FDFC5837CDE346AC9065FF0D30351D85D6021A2834367BD74D5447D355EFDF3290F18B056E2CE43D3FDAB89");

            _sshListener = new ServerListener(_logger);

            _sshListener.Start();

            _logger.Debug("Server Listener instantiated & started");
        }

        public void Start()
        {
            // this method serves only to fire up the WCF service
            // WCF itself does not perform any action,
            // it merely allows for the TCP connection to be established,
            // from where the SBB libraries take over
        }
    }
}
